#include<bits/stdc++.h>
#define y1 Y1
#define fi first
#define endl "\n"
#define se second
#define PI acos(-1)
#define int long long
#define pb(x) push_back(x)
#define PII pair<int, int>
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define _for(i, a, b) for(int i = a; i <= b; ++i)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;

const int N = 2e5 + 10;
int a[N], b[N];
int n, m;
string s;

signed main() {
	IOS;
	int t;
	cin >> t;
	while(t -- ) {
		bool flag = true;
		cin >> n;
		_for(i, 1, n) {
			cin >> a[i];
			b[i] = a[i];
		}
		sort(a + 1, a + n);
		if(a[n] >= a[n - 1]) {
		//	flag = false;
			cout << "YES" << endl;
			continue;
		}
		
		_for(i, 1, n) {
			a[i] = b[i];
		}
		sort(a + 2, a + n + 1);
		if(a[1] <= a[2]) {
			flag = false;
			cout << "YES" << endl;
			continue;
		}
		cout << "NO" << endl; 
	}
	return 0;
}
/*
3
4
1 3 2 4
3
3 5 2
1
1
*/

